<?php
define('PUBLIC_PATH', realpath(dirname(__FILE__)));
define('ROOT_PATH', realpath(PUBLIC_PATH . '/../'));
define('APPLICATION_PATH', ROOT_PATH . '/application');
define('MODULES_PATH', APPLICATION_PATH . '/modules');
define('TEMPLATES_PATH', APPLICATION_PATH . '/templates');
define('DATA_PATH', ROOT_PATH . '/data');

if(isset($_GET['env'])){
	$potentialEnv = strtolower($_GET['env']);
	if(in_array($potentialEnv, array('development','staging','production'))){
		define('APPLICATION_ENV', $potentialEnv);
	} else {
		throw new Exception("Environment must be either development, staging, or production.");
	}
} else {
	define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development');
}

set_include_path(implode(PATH_SEPARATOR, array(
	ROOT_PATH . '/library',
	ROOT_PATH . '/library/incubator',
	get_include_path()
)));

$displayErrors = (int)(APPLICATION_ENV === 'development');
if(stristr($_SERVER['REQUEST_URI'],'install')){
	$bootstrapPath 		= 'Solvex/Bootstrap/Install.php';
	$bootstrapClass		= 'Solvex_Bootstrap_Installer';
} else {
	$bootstrapPath 		= 'Solvex/Bootstrap.php';
	$bootstrapClass		= 'Solvex_Bootstrap';
}

/** setup bootstrap config */
$bootstrapConfig = array(
    'bootstrap' => array(
        'path' => $bootstrapPath,
        'class' => $bootstrapClass
    ),
    'phpSettings' => array(
        'display_startup_errors' => $displayErrors,
        'display_errors' => $displayErrors
    )
);

require_once 'Zend/Application.php';
$application = new Zend_Application(APPLICATION_ENV,$bootstrapConfig);
$application->bootstrap()->run();